---
title: Inspect and flatten PDF form fields
summary: Detect AcroForm fields and, when present, flatten them to make them non-editable.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-17
library: PdfAPI.SyncFusionCore
reference_type: package
operation_id: OP-SFC-013
trigger: PdfService call sites, when the caller opts out of the remote client
---

# Inspect and flatten PDF form fields

Provides two related utilities: detecting whether a PDF has AcroForm fields, and flattening those fields (making them non-editable) when present.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-SFC-013 |
| **Trigger** | `PdfAPI\Services\PdfService.cs:38` and `:45`, used when the caller opts out of the remote client |
| **Inputs** | `byte[]` PDF |
| **Outputs** | `bool` (`HasFormFields`) or `byte[]` (`Flatten`) |
| **Primary components** | `PdfHelper.HasFormFields`, `PdfHelper.Flatten` |
| **Entry point** | `PdfApi.SyncFusionCore\PdfHelper.cs` |

## Steps

1. `HasFormFields`: load the bytes as a `PdfLoadedDocument` inside a `using` and return
   `doc.Form != null` ([BR-SFC-034](../business-rules.md#br-sfc-034-form-fields-detected-by-non-null-form)).
2. `Flatten`: load the bytes as a `PdfLoadedDocument`; when `doc.Form != null`, set
   `Form.Flatten = true`, save to a `MemoryStream` and return the new bytes ([BR-SFC-035](../business-rules.md#br-sfc-035-flatten-makes-fields-non-editable)).
   - If the document has no form: return the original input bytes unchanged ([BR-SFC-036](../business-rules.md#br-sfc-036-flatten-without-form-returns-input-unchanged)).

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start(["HasFormFields or Flatten<br>called with PDF bytes"]) --> Load["Load bytes as<br>PdfLoadedDocument"]
	Load --> Which{"Which call?"}
	Which -->|HasFormFields| CheckForm{"doc.Form != null?"}
	CheckForm -->|Yes| ReturnTrue([Return true])
	CheckForm -->|No| ReturnFalse([Return false])
	Which -->|Flatten| CheckForm2{"doc.Form != null?"}
	CheckForm2 -->|Yes| SetFlatten["Set Form.Flatten = true,<br>save to MemoryStream"]
	SetFlatten --> ReturnFlattened([Return flattened bytes])
	CheckForm2 -->|No| ReturnOriginal(["Return original bytes<br>unchanged"])
```

## Failure and edge-case behavior

- A PDF with no `Form` present is a normal, non-error outcome for both methods: `HasFormFields`
  returns `false` and `Flatten` returns the input unchanged.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `PdfApi.SyncFusionCore\PdfHelper.cs`
- `PdfAPI\Services\PdfService.cs`
